package com.lecture.java8.excel;

import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.read.builder.ExcelReaderBuilder;
import com.lecture.java8.excel.model.UserInfo;

import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.List;

/**
 * @author luyn
 * @description
 * @Date 2020/9/25 9:09
 * @Version 1.0
 */
public class ExcelUtil {

    public static <T> List<T> read(String fileName, Class<T> tClass) {
        try {
            DataListener<T> dataListener = new DataListener<>();
            InputStream is = new FileInputStream(new File(fileName));
            ExcelReaderBuilder read = EasyExcel.read(is, tClass, dataListener);
            read.doReadAll();
            return dataListener.getDataList();
        } catch (Exception e) {

        }
        return null;
    }

    public static void getUserInfo(UserInfo userInfo) {
        userInfo.setName("修改名称");
    }

    public static int getInt(int i) {
        i = 10;
        return i;
    }

    public static String  getStr(String str) {
        str = "修改了字符串";
        return str;
    }
}